from selenium import webdriver
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.chrome.options import Options
'''
	基础页面，所有PO页面继承此页面，页面基础操作方法全部定义在此类中
'''
class BasePage:
	def __init__(self,driver = None):
		if driver == None:
			# self.driver =webdriver.Chrome()
			option = Options()
			option.debugger_address = '127.0.0.1:9222'
			self.driver = webdriver.Chrome(options=option)
		else:
			self.driver = driver

	'''
		元素点击方法，入参：元素定位方式和元素坐标
	'''
	def click(self,by,element):
		self.find(by,element).click()

	'''
		元素输入方法，入参：元素定位方式，元素坐标，输入值
	'''
	def sendKeys(self,by,element,value):
		self.find(by,element).send_keys(value)

	'''
		元素寻找采用显式等待，默认15秒
	'''
	def find(self,by,element):
		return WebDriverWait(self.driver, 15).until(expected_conditions.visibility_of_element_located((by, element)))